<script lang="ts" setup name="SealConfirm">
import SealButton from '@/components/button/index.vue'
import { onMounted } from 'vue';
import { ref } from 'vue';

withDefaults(defineProps<{
    title?:string
    text:string
    confirmCallback:()=>void
    cancelCallback:()=>void
}>(),{
    title:'温馨提示'
})

// const confirm = ()=>{
//     console.log("点击了确认");
//     // 确认之后的业务逻辑  不能在这里写，封装组件，不知道用户确认之后的逻辑
// }

// const cancel = ()=>{
//     console.log("点击了取消");
// }

const flag= ref(false)
onMounted(()=>{
    flag.value = true
})

</script>
<template>
  <Transition name="confirm">
    <div class="seal-confirm" v-if="flag">
    <div class="wrapper">
      <div class="header">
        <h3>{{title}}</h3>
        <a href="JavaScript:;" class="iconfont icon-close-new"></a>
      </div>
      <div class="body">
        <i class="iconfont icon-warning"></i>
        <span>{{text}}</span>
      </div>
      <div class="footer">
        <SealButton size="mini" type="gray" @click="cancelCallback">取消</SealButton>
        <SealButton size="mini" type="primary" @click="confirmCallback">确认</SealButton>
      </div>
    </div>
    </div>
  </Transition>
 
</template>

<style scoped lang="less">
.seal-confirm {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 8888;
  background: rgba(0, 0, 0, 0.5);
  .wrapper {
    width: 400px;
    background: #fff;
    border-radius: 4px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    .header,
    .footer {
      height: 50px;
      line-height: 50px;
      padding: 0 20px;
    }
    .body {
      padding: 20px 40px;
      font-size: 16px;
      .icon-warning {
        color: @priceColor;
        margin-right: 3px;
        font-size: 16px;
      }
    }
    .footer {
      text-align: right;
      .seal-button {
        margin-left: 20px;
      }
    }
    .header {
      position: relative;
      h3 {
        font-weight: normal;
        font-size: 18px;
      }
      a {
        position: absolute;
        right: 15px;
        top: 15px;
        font-size: 20px;
        width: 20px;
        height: 20px;
        line-height: 20px;
        text-align: center;
        color: #999;
        &:hover {
          color: #666;
        }
      }
    }
  }
}

.confirm-enter-from {
    opacity: 0;
}

.confirm-enter-active {
    transition: all .5s;
}

.confirm-enter-to {
    opacity: 1;
}
</style>
